﻿@using Kugar.AdminLte.Core.Test.Models.Home
@using Kugar.Core.ExtMethod
@using Kugar.UI.Web.AdminLTE.Enums
@using Kugar.UI.Web.AdminLTE.Helpers
@using Kugar.UI.Web.AdminLTE.Helpers.FormExtMethod
@using Kugar.UI.Web.AdminLTE.PageControls.PageForms
@using Newtonsoft.Json.Linq
@using Kugar.UI.Web.AdminLTE.PageControls
@using Kugar.UI.Web.AdminLTE.PageControls.Helpers.ButtonExtMethod

@model Model_List

@{
    WebUI.Title = "Tab";
    WebUI.CurrentMenuKey = "Tab";
}

<script>
    function cmdCallback(re) {
        console.log('cmdCallback', re);
    }

    function onModalSuccessCallback() {
        console.log('onModalSuccessCallback');
    }

    function onModalCloseCallback() {
        console.log('onModalCloseCallback');
    }

    function OnSelectedCallback(data) {
        console.log('OnSelectedCallback');
        console.log(data);
    }

    function OnShowCallback() {
        console.log('OnShowCallback');
    }

</script>

@using (var tab = WebUI.Control.Tab()
    .QueryKey("tag")
.AddPage("详情", "info")
.AddPage("日志", "log")
.Side(TabSideEnum.Left)
.LeftTabWidth(52)
.Render())
{
    using (tab.RenderPage("info").Render())
    {
        using (var frm = WebUI.Control.Form().Post().Render())
        {
            <div class="col-xs-6">
                @frm.AddCheckBoxList().LabelWidth(4).ControlWidth("100%").Label("checkbox").Options(new[]
                {
                    new SelectorItem("c0", "0"),
                    new SelectorItem("c1", "1"),
                    new SelectorItem("c2", "2"),
                }).Name("checkbox").Render()
                @frm.AddLabel().LabelWidth(4).ControlWidth("100%").Label("label").Value("label").Render()
                @frm.AddLabel().LabelWidth(4).ControlWidth("100%").Label("label").Value("label").Render()
            </div>

            <div class="col-xs-6">
                @frm.AddLabel().LabelWidth(4).ControlWidth("100%").Label("label").Value("label").Render()
                @frm.AddLabel().LabelWidth(4).ControlWidth("100%").Label("label").Value("label").Render()
                @frm.AddLabel().LabelWidth(4).ControlWidth("100%").Label("label").Value("label").Render()
            </div>

            <div class="col-xs-12">
                @frm.AddCustomContent().Label("CustomContent").Required().Content(@<div>
                    @WebUI.Control.Button().Text("showModal").ShowModal("/Home/ModalWindow").Type(ButtonTypeEnum.button).Color(ColorPaletteEnum.success).Render()
                </div>).Render()

                @frm.AddTextBox().LabelWidth(2).Tips("auyuaa").Required().Label("textbox").Value("sdfsdfsd").Name("txt").SelectedOnClick().Render()

                @frm.AddSelector().Tips("aaygujbna").Label("selector").Required().FirstItem(new SelectorItem("select", "-1")).Options(new[]
                {
                    new SelectorItem("s0", "0"),
                    new SelectorItem("s1", "1"),
                    new SelectorItem("s2", "2"),
                }).Name("select").CurrentValue(1).OnChangedScript("SelectorChange(this);").Render()

                @frm.AddDatetime().Tips("afffaa").ValueLimit(DateTime.Now.AddDays(-5), DateTime.Now.AddDays(5)).ReadOnly().Label("datetimepicker").Name("date").Required().Value(DateTime.Now).Type(DatetimePickerType.Datetime).Format("yyyy-MM-dd HH:mm:ss").Render()

                @frm.AddDatetimeRange().Required().Tips("aaamm").Label("datetimerange").ReadOnly(true, true).ValueLimit(DateTime.Now.AddDays(-5), DateTime.Now.AddDays(5)).Name("startDt", "endDt").Value(DateTime.Now, DateTime.Now).Type(DatetimePickerType.Datetime).Format("yyyy-MM-dd HH:mm:ss").Render()

                @frm.AddCheckBoxList().Label("checkboxlist").Options(new[]
                {
                    new SelectorItem("sss222", "sss"),
                    new SelectorItem("sss333", "sss"),
                }).Name("dddd").Render()

                @frm.AddTextBoxWithButton().ShowDataPicker("/Home/DataPicker",new JObject()
                {
                    {"#dss","ssss" }
                }).SelectedOnClick().Label("datapicker").Value("sdfsdfsd").Name("dddd").Render()
            </div>

            frm.AddButtonList().LabelWidth(0)
                .AddButton(x => x.Text("save").Type(ButtonTypeEnum.submit).Color(ColorPaletteEnum.success))
                .AddButton(x => x.Text("cancel").Type(ButtonTypeEnum.button).Color(ColorPaletteEnum.@default))
                .Render();

            //WebUI.Control.PanelBox()
            //    .AddFooterButton(x => x.Text("save").Type(ButtonTypeEnum.submit).Color(ColorPaletteEnum.success))
            //    .AddFooterButton(x => x.Text("cancel").Type(ButtonTypeEnum.button).Color(ColorPaletteEnum.@default))
            //    .Render();

        }
    }

    using (tab.RenderPage("log").Render())
    {
        using (var tbl = WebUI.Control.Table<TableTest>().Data(Model.Data).LeftFixedColumn(1).RightFixedColumn(1).FillRowCount(10).NoWrap().Render())
        {
            @tbl.Columns.AddIndex()

            @tbl.Columns.AddLabel().ColumnTitle("UserName1").Value(x => x.UserName1)

            @tbl.Columns.AddLabel().ColumnTitle("UserName2").Value(x => x.UserName2)

            @tbl.Columns.AddLabel().ColumnTitle("UserName3").Value(x => x.UserName3.ToStringEx("yyyy-MM-dd"))

            @tbl.Columns.AddLabel().ColumnTitle("UserName4").Value(x => x.UserName4.ToString())

            @tbl.Columns.AddLabel().ColumnTitle("UserName5").Value(x => x.UserName5)

            @tbl.Columns.AddLabel().ColumnTitle("UserName6").Value(x => x.UserName6)

            @tbl.Columns.AddLabel().ColumnTitle("UserName7").Value(x => x.UserName7)

            @tbl.Columns.AddLabel().ColumnTitle("UserName8").Value(x => x.UserName8)

            @(tbl.Columns.AddButtonList().MenuTitle("操作").ButtonType(ColumnDropdownButtonType.DropdownList)
                         .AddButton((data, btn) => btn.Text("b1").Color(ColorPaletteEnum.primary))
                         .AddButton((data, btn) => btn.Text("b2").Color(ColorPaletteEnum.primary))
                         .AddButton((data, btn) => btn.Text("b3").Color(ColorPaletteEnum.primary))
                         .AddButton((data, btn) => btn.Text("b4").Color(ColorPaletteEnum.warning))
                         .AddButton((data, btn) => btn.Text("b5").Color(ColorPaletteEnum.danger)))
        }
    }
}
